package cn.com.pureAppApi.controller;

import java.util.Arrays;
import java.util.Map;
import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import cn.com.pureAppApi.entity.vo.AuthoritiesEntityVo;
import cn.com.pureAppApi.entity.AuthoritiesEntity;
import cn.com.pureAppApi.service.IAuthoritiesService;

import  cn.com.pureAppApi.utils.PageUtils;
import  cn.com.pureAppApi.utils.ResponseResult;
import  cn.com.pureAppApi.utils.ResponseCommon;


/**
 * InnoDB free: 10240 kB
 *
 * QQ讨论群:76989293
 * @email 2696701142@qq.com
 * @date 2018-06-12 16:51:48
 */
@RestController
@RequestMapping("pureAppApi/authorities")
public class AuthoritiesController {
    @Autowired
    private IAuthoritiesService authoritiesService;

	 /**
     *  接口返回VO 列表
     */  
   	@ApiOperation(value = "list分页列表Vo", notes = "")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "page", value = "第几页:默认0", required = false, dataType = "int",paramType="query"),
			@ApiImplicitParam(name = "rows", value = "每页的行数 默认20", required = false, dataType = "int",paramType="query")})
	@GetMapping("findListByPagevo")
	public ResponseCommon<List<AuthoritiesEntityVo>> findListByPagevos(@RequestParam(defaultValue="0") Integer page,@RequestParam(defaultValue="20") Integer rows) {
		return new ResponseCommon<List<AuthoritiesEntityVo>>(authoritiesService.findListPageVo(page, rows));
	}
	/**
     * 接口 参数查找列表  接口返回VO 列表
     */ 
   	@ApiOperation(value = "listPageByParam列表Vo", notes = "")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "page", value = "第几页:默认0", required = false, dataType = "int",paramType="query"),
			@ApiImplicitParam(name = "rows", value = "每页的行数 默认20", required = false, dataType = "int",paramType="query"),
			@ApiImplicitParam(name = "oneByParamId", value = "参数说明", required = true, dataType = "Long",paramType="query")})
	@GetMapping("findListPageVoByParamId")
	public ResponseCommon<List<AuthoritiesEntityVo>> findListPageVoByParamIds(@RequestParam(defaultValue="0") Integer page,@RequestParam(defaultValue="10") Integer rows,@RequestParam Long oneByParamId) {
		return new ResponseCommon<List<AuthoritiesEntityVo>>(authoritiesService.findListPageVoByParamId(page, rows, oneByParamId));
	}
	/**
     * 接口 参数查找对象  接口返回VO 列表
     */ 
   	@ApiOperation(value = "listPageByParam列表Vo", notes = "")
	@ApiImplicitParams({
 			@ApiImplicitParam(name = "oneByParamId", value = "参数说明", required = true, dataType = "Long",paramType="query")
			})
	@GetMapping("findSelectOneVoByParamId")
	public ResponseCommon<AuthoritiesEntityVo> findSelectOneVoByParamIds(@RequestParam(defaultValue="0") Integer page,@RequestParam(defaultValue="10") Integer rows,@RequestParam Long oneByParamId) {
		return new ResponseCommon<AuthoritiesEntityVo>(authoritiesService.findSelectOneVoByParamId(oneByParamId));
	}
	 /**
     * 插入 返回对象 返回VO 
     */
	@ApiOperation(value = "保存接口VO", notes = "")  
	@PostMapping("insertReturnVo")
	public ResponseCommon<AuthoritiesEntityVo>  insertReturnVos(			
			@RequestBody    AuthoritiesEntityVo vo) {		
		AuthoritiesEntityVo result= authoritiesService.insertReturnVo(vo);		
		return new ResponseCommon<>(result);
	}
	
	/**
     * 编辑 返回对象 返回VO 
     */
	@ApiOperation(value = "修改接口VO", notes = "")  
	@PutMapping("editReturnVo")	
	public ResponseCommon<AuthoritiesEntityVo>  editReturnVos(			
			@RequestBody    AuthoritiesEntityVo vo) {		
		AuthoritiesEntityVo result= authoritiesService.editReturnVo(vo);		
		return new ResponseCommon<>(result);
	}	
	 /**
     * 接口 列表
     */  
   	@ApiOperation(value = "list分页列表", notes = "")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "page", value = "第几页:默认0", required = false, dataType = "int",paramType="query"),
			@ApiImplicitParam(name = "rows", value = "每页的行数 默认20", required = false, dataType = "int",paramType="query")})
	@GetMapping("findListByPage")
	public ResponseCommon<List<AuthoritiesEntity>> findListByPages(@RequestParam(defaultValue="0") Integer page,@RequestParam(defaultValue="20") Integer rows) {
		return new ResponseCommon<List<AuthoritiesEntity>>(authoritiesService.findListPage(page, rows));
	}

	/**
     * 接口 参数查找列表
     */ 
   @ApiOperation(value = "listPageByParam列表", notes = "")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "page", value = "第几页:默认0", required = false, dataType = "int",paramType="query"),
			@ApiImplicitParam(name = "rows", value = "每页的行数 默认20", required = false, dataType = "int",paramType="query"),
			@ApiImplicitParam(name = "oneByParamId", value = "参数说明", required = true, dataType = "Long",paramType="query")})
	@GetMapping("findListPageByParamId")
	public ResponseCommon<List<AuthoritiesEntity>> findListPageByParamIds(@RequestParam(defaultValue="0") Integer page,@RequestParam(defaultValue="10") Integer rows,@RequestParam Long oneByParamId) {
		return new ResponseCommon<List<AuthoritiesEntity>>(authoritiesService.findListByParamId(page, rows, oneByParamId));
	}	
	
	 /**
     * 插入 返回对象
     */
	@ApiOperation(value = "插入数据接口", notes = "")  
	@PostMapping("insert")
	public ResponseCommon<AuthoritiesEntity>  inserts(			
			@RequestBody    AuthoritiesEntity vo) {		
		AuthoritiesEntity result= authoritiesService.insert(vo);		
		return new ResponseCommon<>(result);
	}
	
	/**
     * 编辑 返回对象
     */
	@ApiOperation(value = "修改数据接口", notes = "")  
	@PutMapping("edit")	
	public ResponseCommon<AuthoritiesEntity>  edits(			
			@RequestBody    AuthoritiesEntity vo) {		
		AuthoritiesEntity result= authoritiesService.edit(vo);		
		return new ResponseCommon<>(result);
	}	
	
   /**
	 * 保存
	 */
	@ApiOperation(value = "保存接口", notes = "")  
	//@ResponseBody
	@PostMapping("/save")	
	public ResponseResult save(@RequestBody    AuthoritiesEntity vo){
		if(authoritiesService.save(vo)>0){
			return ResponseResult.ok();
		}
		return ResponseResult.error();
	}
	/**
	 * 修改
	 */
	@ApiOperation(value = "修改接口", notes = "") 
	@PutMapping("/update")	
	public ResponseResult update(@RequestBody    AuthoritiesEntity vo){
		authoritiesService.update(vo);
		return ResponseResult.ok();
	}
	
	/**
	 * 删除
	 */
	@ApiOperation(value = "删除接口", notes = "delete") 
	@DeleteMapping("delete")
	public ResponseResult remove( Integer id){
		if(authoritiesService.remove(id)>0){
		return ResponseResult.ok();
		}
		return ResponseResult.error();
	}
}
